import { deptOptions } from "@/api/system/dept.js";
import { options } from "@/api/job/termAttendanceGroup/termAttendanceGroup_v2";

const depts = {
  state: {
    deptOptions: [],
    groupOptions: []
  },
  mutations: {
    SET_OPTIONS: (state, options) => {
      state.deptOptions = options;
    },
    SET_GROUP_OPTIONS: (state, options) => {
      state.groupOptions = options;
    }
  },
  actions: {
    // 获取班组可选项
    getDeptOptions({ commit }) {
      return new Promise((resolve, reject) => {
        deptOptions(3).then(res => {
          commit("SET_OPTIONS", res.data);
          resolve(res.data);
        });
      });
    },
    // 获取考勤组可选项
    getGroupOptions({ commit }) {
      return new Promise((resolve, reject) => {
        options().then(res => {
          commit("SET_GROUP_OPTIONS", res.data);
          resolve(res.data);
        });
      });
    }
  }
};

export default depts;
